#ifndef QWEEKLYTIMER_H
#define QWEEKLYTIMER_H

#include <QTimer>
#include <QtDebug>
#include <QDateTime>

class QWeeklyTimer : public QTimer
{
    Q_OBJECT
private:
    Qt::DayOfWeek _dayofweek;
    int _hours, _minutes, _seconds;
    QDateTime* _nextschedule;
    QTimer* _internaltimer;

private:
    void initTimer();
    int dayNumber(Qt::DayOfWeek dow);
    bool isNowTheTime();
    void setInterval(int msec);
    void assignTimeValues(Qt::DayOfWeek dow, int h, int m);

private slots:
    virtual void internalTimer_timedout();

public:
    QWeeklyTimer(Qt::DayOfWeek dow, int h=0, int m=0);
    QDateTime* nextSchedule();
    void reschedule(Qt::DayOfWeek dow, int h=0, int m=0);

public slots:
    void start();
    void stop();
};

#endif // QWEEKLYTIMER_H
